-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix/prometheus metadata sorting #12112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
|
@blueorangutan package |
|
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12112 +/- ##
=========================================
Coverage 17.55% 17.56%
- Complexity 15535 15541 +6
=========================================
Files 5911 5911
Lines 529359 529377 +18
Branches 64655 64656 +1
=========================================
+ Hits 92949 92993 +44
+ Misses 425952 425924 -28
- Partials 10458 10460 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15807 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian Build Failed (tid-14851) |
| if (!item.name.equals(currentMetricName)) { | ||
| currentMetricName = item.name; | ||
| stringBuilder.append("# HELP ").append(currentMetricName).append(" ") | ||
| .append(item.getHelp()).append("\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Sinscerly - I have a question around the metrics using tags in which you have modified the help text - if not mistaken the text won't be updated as the modification will happen after invoking item.toMetricsString() so at this line the previous help text will be displayed, is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nvazquez,
The HELP and TYPE only have to be added before each group of metrics. Only once for cloudstack_domain_resource_count, regardless of how many items with different tags share that metric name.
Does this clarify your question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sinscerly sorry for the delay. My concern was only for the metrics that override the help field on the item.toMetricsString() call.
For example:
On the metrics iteration, when creating the metrics string for ItemHostCpu the string will always start with the default HELP text (Host CPU usage in MHz) despite having tags or not - I see in case the metric contains tags it should display Host CPU usage in MHz grouped by host tags. Please correct me if I'm wrong
Additionally, I think this if block if (!item.name.equals(currentMetricName)) can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nvazquez,
Well the item ItemHostCpu returns two different metrics: cloudstack_host_cpu_usage_mhz_total and cloudstack_host_cpu_usage_mhz_total_by_tag. I just made sure the correct help line is outputted for that metric.
In the end all metrics are sorted and each unique help line is added. so this will give:
# HELP cloudstack_host_cpu_usage_mhz_total <help description>
... metrics for above type
... ''
# HELP cloudstack_host_cpu_usage_mhz_total_by_tag <help description>
... metrics for above type
So it seemed logical for me to also change that. Although I'm doubting it will work, as the toMetricsString is called after adding in the HELP and TYPE I see. Although this would require some bigger rework of adding metrics I think, split it up in separate items.
Removing the if (!item.name.equals(currentMetricName)) will cause harm as you only want it once for every unique metric name. As you want:
# HELP cloudstack_domain_resource_count Resource usage count per domain
# TYPE cloudstack_domain_resource_count gauge
cloudstack_domain_resource_count{domain="/", type="memory"} 0
cloudstack_domain_resource_count{domain="/", type="cpu"} 0
cloudstack_domain_resource_count{domain="/", type="gpu"} 0
cloudstack_domain_resource_count{domain="/", type="primary_storage"} 0
And not the HELP and TYPE for every single metric item:
# HELP cloudstack_domain_resource_count Resource usage count per domain
# TYPE cloudstack_domain_resource_count gauge
cloudstack_domain_resource_count{domain="/", type="memory"} 0
# HELP cloudstack_domain_resource_count Resource usage count per domain
# TYPE cloudstack_domain_resource_count gauge
cloudstack_domain_resource_count{domain="/", type="cpu"} 0
# HELP cloudstack_domain_resource_count Resource usage count per domain
# TYPE cloudstack_domain_resource_count gauge
cloudstack_domain_resource_count{domain="/", type="gpu"} 0
# HELP cloudstack_domain_resource_count Resource usage count per domain
# TYPE cloudstack_domain_resource_count gauge
cloudstack_domain_resource_count{domain="/", type="primary_storage"} 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Sinscerly please ignore my second comment then :)
About the first one, do you think that can be addressed on a separate PR, leaving this PR as it is now?
|
[SF] Trillian Build Failed (tid-14866) |
|
[SF] Trillian test result (tid-14870)
|
|
@kiranchavala @NuxRo , can you guys have a look at this? |
|
@Sinscerly , given comment #12112 (comment), will you work on this more or do you want this merged as is? cc @kiranchavala @NuxRo @nvazquez |
NuxRo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested briefly, LGTM, good job @Sinscerly
|
@kiranchavala @nvazquez @Sinscerly , will we merge as is and addresst the rest in further issues ? |
Description
This PR adds Prometheus metadata to all metrics types. Therefor Prometheus can include the TYPE and HELP information when scraping the endpoint.
See more details in #12110.
Fixes: #12110
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
I've tested the code change with a simplistic setup (didn't got all running, @abh1sar could you test it together more fully with your extra Prometheus metrics as my dev environment is still not working correctly)
I've successfully seen that the TYPE and HELP information is added to the nicely sorted list of metrics the exporter provides.
How did you try to break this feature and the system with this change?
I've enabled the Prometheus exporter and queried the endpoint multiple times to see the data came out like this: